<%-- 
    Document   : SanPhamApContent
    Created on : Oct 26, 2011, 10:01:11 PM
    Author     : kijoo
--%>

<%@page import="MODEL.POJO.*"%>
<%@page import="java.util.ArrayList"%>
<%@page import="MODEL.DAO.LoaiSanPhamDAO"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE html>
<%
    LoaiDanhMucPOJO loaidm = (LoaiDanhMucPOJO) request.getAttribute("LoaiDanhMucA");
    SanPhamPOJO sanp = (SanPhamPOJO) request.getAttribute("TenSanPham");
    String loaisanpham = (String) request.getAttribute("LoaiSanPhams");
    String maloaisp=(String) session.getAttribute("IDLoaiSanPham");
    int soluongtrang = (Integer) request.getAttribute("SoTrang");
    int xuly = (Integer) request.getAttribute("XyLy");
%>
<div id="dmchon">
    <strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%=loaidm.getTenloaidanhmuc()%>
    </strong>
</div> 
<div class="noidung">
    <%
        ArrayList<ChiTietSanPhamPOJO> dsctsp = (ArrayList<ChiTietSanPhamPOJO>) request.getAttribute("DanhSachCTSPs");
        for (int j = 0; j < dsctsp.size(); j++) {
            ChiTietSanPhamPOJO ctsp = dsctsp.get(j);
    %>
    <table width="100%" border="0" align="center">
        <tr>
            <td width="19%">&nbsp;</td>
            <td width="61%"><a title="<%=ctsp.getTensanpham()%>" href="ChiTietAPController?Action=<%=loaisanpham%>&idchitietsanpham=<%=ctsp.getIdchitietsanpham()%>&idloaisanpham=<%=maloaisp%>&idloaidanhmuc=<%=loaidm.getIdloaidanhmuc()%>&tenloaidanhmuc=<%=loaidm.getTenloaidanhmuc()%>" style="color:#FF0000; font-size:16px;"><strong><span style="color:#0066FF; CURSOR: hand" onMouseOver="this.style.color='#FF0000'; " onMouseOut="this.style.color='#0066FF'; "><%=ctsp.getTensanpham()%></span></strong></a></td>
            <td width="20%">&nbsp;</td>
        </tr>
        <tr>
            <td rowspan="3"><div align="center"><a href="ChiTietAPController?Action=<%=loaisanpham%>&idchitietsanpham=<%=ctsp.getIdchitietsanpham()%>&idloaidanhmuc=<%=loaidm.getIdloaidanhmuc()%>&tenloaidanhmuc=<%=loaidm.getTenloaidanhmuc()%>&idloaisanpham=<%=maloaisp%>"><img src="<%=ctsp.getHinh()%>" /></a></div></td>
            <td><strong>Model: </strong>MC984ZP/A</td>
            <td><div align="center" style="color:#FF0000"><%=ctsp.getGiaban()%> VNĐ</div></td>
        </tr>
        <tr>
            <td><%=ctsp.getMota()%></td>
            <td><div align="center"><div align="center"><div class="muahang"><a href="CartAppleController?Action=ChoVaoGioHang&idloaisanpham=<%=request.getParameter("Action")%>&idchitietsanpham=<%=ctsp.getIdchitietsanpham()%>"><img src="images/dathang1.gif"/></a></div></td>
        </tr>
        <tr>
            <td><strong>Bảo hành</strong> <%=ctsp.getBaohanh()%> Tháng | <strong>Kho hàng </strong><%=ctsp.getSoluongton()%></td>
            <td><div align="center"><a href="ChiTietAPController?Action=<%=loaisanpham%>&idchitietsanpham=<%=ctsp.getIdchitietsanpham()%>&idloaisanpham=<%=maloaisp%>&idloaidanhmuc=<%=loaidm.getIdloaidanhmuc()%>&tenloaidanhmuc=<%=loaidm.getTenloaidanhmuc()%>">[ Xem th&ecirc;m ]</a></div></td>
        </tr>
        <tr>
            <td><div align="center">Lượt xem <%=ctsp.getSolanxem()%></div></td>
            <td><strong>Vận chuyển</strong> To&agrave;n qu&#7889;c</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td><strong>Khuyến mãi</strong> &nbsp; Mi&#7871;ng d&aacute;n m&agrave;n h&igrave;nh</td>
            <td>&nbsp;</td>
        </tr>

    </table>
    <hr>
    <% }%>
    <%-- phan trang --%>
    <div>
        <%  int trangtruoc = 1;
            if (request.getParameter("Trang") != null) {
                int tranghienhanh = Integer.parseInt(request.getParameter("Trang"));
                if (tranghienhanh > 1) {
                    trangtruoc = tranghienhanh - 1;
                }
            }
        %>
        <%-- xu ly hien thi phan trang voi link --%>
        <%
            if (xuly == 1) {
        %>
        <a  href="DanhSachSanPhamAPController?Action=<%=loaisanpham%>&idloaidanhmuc=<%=loaidm.getIdloaidanhmuc()%>&tenloaidanhmuc=<%=loaidm.getTenloaidanhmuc()%>&Trang=<%=trangtruoc%>">[Trang trước]</a>Trang: 
        <%
            for (int i = 1; i <= soluongtrang; i++) {%>
            <a href="DanhSachSanPhamAPController?Action=<%=loaisanpham%>&idloaidanhmuc=<%=loaidm.getIdloaidanhmuc()%>&tenloaidanhmuc=<%=loaidm.getTenloaidanhmuc()%>&Trang=<%=i%>"><%=i%></a>
            <% }%>
            <%  int trangsau = trangtruoc + 1;
                if (request.getParameter("Trang") != null) {
                    int tranghienhanh = Integer.parseInt(request.getParameter("Trang"));
                    if (trangsau < soluongtrang) {
                        trangsau = tranghienhanh + 1;
                    }
                }%>
            <a  href="DanhSachSanPhamAPController?Action=<%=loaisanpham%>&idloaidanhmuc=<%=loaidm.getIdloaidanhmuc()%>&tenloaidanhmuc=<%=loaidm.getTenloaidanhmuc()%>&Trang=<%=trangsau%>">[Trang sau]</a>
            <%} %>
  </div>
</div>
